<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>模板管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		function bindTemplate(templateId){
			var tableId = $("#tableId").val();
			var url = "${ctx}/ins/insTable/bindTemplate";
			loading("绑定中，请稍等...");
			$.ajax({
				  type: 'POST',
				  url: url,
				  data: {
					  "id":tableId,
					  "template.id":templateId
				  },
				  success: function(data){
					  var resultJson = eval(data);
					  if(resultJson.code == '200'){
						  closeLoading();
						  alertx(resultJson.message);
					  }else{
						  closeLoading();
						  alertx(resultJson.message);		  
					  }
				  },
				  dataType: "json"
				});
			
		}
	</script>
</head>
<body>
	<form:form id="searchForm" modelAttribute="insTemplate" action="${ctx}/ins/insTemplate/bindList" method="post" class="breadcrumb form-search">
		<input id="tableId" type="hidden" value="${tableId}"/>
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>模板名称：</label>
				<form:input path="name" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>模板名称</th>
				<th>备注</th>
				<th>修改时间</th>
				<shiro:hasPermission name="ins:insTemplate:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="insTemplate">
			<tr>
				<td>
					${insTemplate.name}
				</td>
				<td>
					${insTemplate.remarks}
				</td>
				<td>
					<fmt:formatDate value="${insTemplate.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<shiro:hasPermission name="ins:insTemplate:edit"><td>
    				<a href="${ctx}/ins/insTable/bindTemplate?id=${tableId}&template.id=${insTemplate.id}" onclick="return servicePassword(this.href,'${fns:getUser().name}');">绑定</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>